package com.glp.services.impl;

import com.glp.common.constants.GlpConstants;
import com.glp.dao.custom.UserMapper;
import com.glp.pojo.User;
import com.glp.pojo.dto.UserDTO;
import com.glp.services.UserService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<UserDTO> getUserByRole(int roleId) {
        return userMapper.selectByRoleId(roleId);
    }

    @Override
    public int addUser(User user) {
        return userMapper.insertSelective(user);
    }

    @Override
    public List<User> getAll() {
        return userMapper.selectAll();
    }

    @Override
    public int removeUser(Integer userId) {
        return userMapper.deleteByPrimaryKey(userId);
    }

    @Override
    public User getUserByLoginName(String loginName) {
        return userMapper.selectByLoginName(loginName);
    }
}
